home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 November / Chip 11-96.iso / workshop / howto / nis < prev    next >
Text File  |  1996-05-25  |  20KB  |  535 lines

  1. The Linux NIS(YP)/NIS+/NYS HOWTO
  2. by Andrea Dell'Amico <adellam@di.unipi.it>,
  3.    Mitchum DSouza    <m.dsouza@mrc-apu.cam.ac.uk>,
  4.    Erwin Embsen      <erwin@nioz.nl>
  5. Version 0.2, Last Modified on June 16, 1994
  6.  
  7.  
  8. CONTENTS
  9.  
  10.   0. Glossay of Terms
  11.      0.1. Some General Information
  12.  
  13.   1. Introduction
  14.      1.1. New versions of this document
  15.      1.2. Disclaimer
  16.      1.3. Feedback
  17.      1.4. Acknowledgements
  18.  
  19.   2. NIS or NIS+ (aka. NYS) ?
  20.  
  21.   3. How it works
  22.  
  23.   4. What you need to set up NIS?
  24.  
  25.      4.1. The RPC Portmapper
  26.      4.2. Determine whether you are a Server, Slave or Client.
  27.      4.3. The Software
  28.      4.4. Setting up a NIS Client
  29.  
  30.   5. What you need to set up NYS (NIS+)?
  31.  
  32.      5.1. Determine whether you are a Server, Slave or Client.
  33.      5.2. The Software
  34.      5.3. Setting up a NYS Client
  35.      5.4. The nsswitch.conf File
  36.  
  37.   6. Setting up a NYS server
  38.  
  39.   7. Verifying the NIS Installation
  40.  
  41.   8. Common Problems and Troubleshooting NIS
  42.  
  43.   9. Frequently Asked Questions
  44.  
  45.  
  46.  
  47. 0. Glossary of Terms
  48.  
  49. In this document a lot of acronyms are used. Here are the most
  50. important acronyms and a brief explanation:
  51.  
  52.     DBM      DataBase Management, a library of functions which
  53.              maintain key/content pairs in a data base.
  54.  
  55.     DLL      Dynamically Linked Library, a library linked to an
  56.              executable program at run-time.
  57.  
  58.     FTP      File Transfer Protocol, a protocol used to transfer
  59.              files between two computers.
  60.  
  61.     NIS      Network Information Service, a service that provides
  62.              information, that has to be known throughout the network,
  63.              to all machines on the network.
  64.  
  65.     nsl      network services library, a library of network service
  66.              calls (socket, bind, etc...) on SYSV Unixes.
  67.  
  68.     NYS      This is a mutation of the word NIS and represents the NIS+
  69.              services library written by Peter Eriksson <pen@signum.se>.
  70.   
  71.     RPC      Remote Procedure Call. RPC routines allow C programs to
  72.              make procedure calls on other machines across the network.
  73.  
  74.     YP       Yellow Pages(tm), a registered trademark in the UK of
  75.              British Telecom plc.
  76.  
  77.     TCP/IP   Transmission Control Protocol/Internet Protocol. It's a
  78.              data communication protocol often used on Unix machines.
  79.  
  80.  
  81. 0.1. Some General Information
  82.  
  83. The next three lines are quoted from the Sun(tm) System & Network
  84. Administration Manual:
  85.  
  86.     "NIS was formerly known as Sun Yellow Pages (YP) but
  87.      the name Yellow Pages(tm) is a registered trademark
  88.      in the United Kingdom of British Telecom plc and may
  89.      not be used without permission."
  90.  
  91. NIS stands for Network Information Service. It's purpose is to
  92. provide information, that has to be known throughout the network,
  93. to all machines on the network. Information likely to be
  94. distributed by NIS is:
  95.  
  96.     - login names/passwords/home directories (/etc/passwd)
  97.     - group information (/etc/group)
  98.  
  99. So, for example, if your password entry is recorded in the NIS
  100. passwd database, you will be able to login on all machines on the
  101. net which have the NIS client programs running.
  102.  
  103. Sun is a trademark of Sun Microsystems, Inc. licensed to
  104. SunSoft, Inc.
  105.  
  106.  
  107. 1. Introduction
  108.  
  109. More and more, Linux machines are installed as part of a network of
  110. computers. To simplify network administration, most networks (mostly
  111. Sun-based networks) run the Network Information Service. Linux machines
  112. can take full advantage of existing NIS service or provide NIS service
  113. themselves.
  114. This document tries to answer questions about setting up
  115. NIS(YP)/NIS+/NYS on your Linux machine. Don't forget to read
  116. section 4.1, The RPC Portmapper.
  117.  
  118.  
  119. 1.1. New versions of this document
  120.  
  121. New versions of this document will be posted periodically (about every
  122. month) to the newsgroups comp.os.linux.announce and comp.os.linux.misc.
  123. The document is archived on a number of Linux FTP sites, including
  124. sunsite.unc.edu in pub/Linux/docs/HOWTO.
  125.  
  126.  
  127. 1.2. Disclaimer
  128.  
  129. Although this document has been put together to the best of our
  130. knowledge it may, and probably does contain errors. Please read any
  131. README files that are bundled with any of the various pieces of
  132. software described in this document for more detailed and accurate
  133. information. We will attempt to keep this document as error free as
  134. possible.
  135.  
  136.  
  137. 1.3. Feedback
  138.  
  139. If you have any comments, questions or suggestions please email
  140. them to <erwin@nioz.nl>. Definitely contact him if you find errors
  141. or obvious omissions.
  142.  
  143.  
  144. 1.4. Acknowledgements
  145.  
  146. We would like to thank all the people who have contributed (directly
  147. or indirectly) to this document. In alphabetical order:
  148.  
  149.     Andrea Dell'Amico    <adellam@di.unipi.it>
  150.     Mitchum DSouza    <m.dsouza@mrc-apu.cam.ac.uk>
  151.     Erwin Embsen    <erwin@nioz.nl>
  152.     Byron A Jeff    <byron@cc.gatech.edu>
  153.  
  154.  
  155. 2. NIS or NIS+ (aka. NYS) ?
  156.  
  157. The choice between NIS and NIS+ is a question of flexibility vs.
  158. maturity.  Generally NIS has been around longer and sometimes suffers
  159. from its age, inflexibility, and administration difficulties. NIS+
  160. addresses all these problems, provides more flexibility, is easier to
  161. set up and administer, and is backward compatable with NIS servers and
  162. thus recommended for first time users setting up Linux machines within
  163. a NIS enviroment. However, unlike NIS which is integrated into the
  164. standard C library, NIS+ requires you to relink all deamons and clients
  165. wishing to access these services with the NYS library libnsl.a
  166. (similarly to SYSV - or the shared library libnsl.so). However, once
  167. clients and deamons are compiled with NYS, they bypass the
  168. /etc/host.conf mechanism totally (for host lookups) and determine their
  169. resolving mechanism via the /etc/nsswitch.conf file.
  170.  
  171.  
  172. 3. How it works
  173.  
  174. Within a network there must be at least one machine acting as a NIS
  175. server. If there are more machines in the network providing NIS, then
  176. one machine is said to be the master NIS server and all the other NIS
  177. servers are so-called slave NIS servers. Slave servers only have copies
  178. of the NIS databases and receive these copies from the master NIS
  179. server whenever changes are made to the master's databases.  Depending
  180. on the number of machines in your network and the reliability of your
  181. network, you might decide to install one or more slave servers.
  182. Whenever a NIS server goes down or is too slow in responding to
  183. requests, a NIS client connected to that server will try to find one
  184. that is up or quicker.
  185. With NYS, however, the /etc/nsswitch.conf file determines which host
  186. you want to go to for a particular service (as there is no binding
  187. deamon `ypbind') if your primary NIS server is not running or is too
  188. slow to respond. This adds more flexibility as you are able to choose
  189. on a per-service basis which host should answer what query. For
  190. example, you may specify that if the master server `A' is down then,
  191. for host queries, go to server `B' and for password queries go to
  192. server `C' etc..
  193.  
  194. NIS databases are in so-called DBM format, derived from ASCII
  195. databases.  For example, the files /etc/passwd and /etc/group can be
  196. directly converted to DBM format using ASCII-to-DBM translation
  197. software ('dbload', it's included with the server software). The master
  198. NIS server should have both, the ASCII databases and the DBM databases.
  199. Slave servers or client machines will be notified of any change to the
  200. NIS maps, (via the "ypbind" deamon), and automatically retrieve the
  201. necessary changes in order to synchronize their databases.
  202.  
  203.  
  204. 4. What you need to set up NIS?
  205.  
  206. 4.1. The RPC Portmapper
  207.  
  208. To run any of the software mentioned below you will need to run the
  209. program /usr/sbin/rpc.portmap. Some Linux distributions already have
  210. the code in /etc/rc.d/rc.inet2 to start up this daemon.  All you have
  211. to do is comment it out and reboot your Linux machine to activate it.
  212.  
  213. The RPC portmapper (portmap(8c)) is a server that converts TCP/IP
  214. protocol port numbers into RPC program numbers. It must be running in
  215. order to make RPC calls (which is what the NIS client software does).
  216. When an RPC server is started (like a NIS server program), it will tell
  217. portmap what port number it is listening to, and what RPC program
  218. numbers it is prepared to serve. When a client wishes to make an RPC
  219. call to a given program number, it will first contact portmap on the
  220. server machine to determine the port number where RPC packets should be
  221. sent.
  222.  
  223. Normally, standard RPC servers are started by inetd(8C), so portmap
  224. must be started before inetd is invoked.
  225.  
  226.  
  227. 4.2. Determine whether you are a Server, Slave or Client.
  228.  
  229. To answer this question you have to consider two cases:
  230.  
  231.     1. Your machine is going to be part of a network with
  232.        existing NIS servers
  233.  
  234.     2. You do not have any NIS servers in the network yet
  235.  
  236. In the first case, you only need the client programs (ypbind, ypwhich,
  237. ypcat, yppoll, ypmatch). The most important program is ypbind. This
  238. program must be running at all times, that is, it should always appear
  239. in the list of processes. It's a so-called daemon process and needs to
  240. be started from the system's startup file (eg. /etc/rc.local).
  241. As soon as ypbind is running, your system has become a NIS client.
  242.  
  243. In the second case, if you don't have NIS servers, then you will also
  244. need a NIS server program (usually called ypserv) and you have to
  245. designate one of the machines in your network as a master NIS server.
  246. Note that it is a good practise to designate at least one machine as a
  247. slave server.
  248.  
  249.  
  250. 4.3. The Software
  251.  
  252. The system library "/usr/lib/libc.a" (version 4.4.2 and better) or the
  253. shared library "/usr/lib/libc.sa" and its related DLL contain all
  254. necessary system calls to succesfully compile the NIS client and server
  255. software. Some people reported that NIS only works with
  256. "/usr/lib/libc.a" version 4.5.21 and better so if you want to play it
  257. safe don't user older libc's.  The NIS client software can be obtained
  258. from:
  259.  
  260.   Site                   Directory                        File Name
  261.   
  262.   ftp.uni-paderborn.de   /pub/linux/yp                    yp-linux.tar.gz
  263.   nic.funet.fi           /pub/OS/Linux/util/networking/\
  264.                             util-swan/Programs/System/yp/ yp-linux.tar.gz
  265.   sunsite.unc.edu        /pub/Linux/system/Network/admin  yp-clients.tar.gz
  266.  
  267. Once you obtained the software, please follow the instructions which
  268. come with the software.
  269.  
  270.  
  271. 4.4. Setting up a NIS Client
  272.  
  273. Assuming you have succesfully compiled the software you are now ready
  274. to install the software. A suitable place for the ypbind daemon is
  275. the directory /usr/sbin.
  276.  
  277. You'll need to do this as root of course. The other binaries (ypwhich,
  278. ypcat, yppoll, ypmatch) should go in a directory accessible by all
  279. users, for example /usr/etc or /usr/local/bin.  It might be a good idea
  280. to test ypbind before incorporating it in /etc/rc.d/rc.inet2.
  281.  
  282. To test ypbind do the following:
  283.  
  284.     - Make sure you have your domain name set. If it is not
  285.       set then issue the command:
  286.  
  287.         /bin/domainname my.domain
  288.  
  289.       where my.domain is the domain your machine is part of.
  290.  
  291.     - Start up "/usr/sbin/rpc.portmap" if it is not already running.
  292.  
  293.     - Create the directory "/var/yp" if it does not exist.
  294.  
  295.     - Start up "/usr/sbin/ypbind"
  296.  
  297.     - Use the command "rpcinfo -p localhost" to check if ypbind
  298.       was able to register its service with the portmapper. The
  299.       rpcinfo should produce something like:
  300.  
  301.        program vers proto   port
  302.         100000    2   tcp    111  portmapper
  303.         100000    2   udp    111  portmapper
  304.         100007    2   udp    637  ypbind
  305.         100007    2   tcp    639  ypbind
  306.         300019    1   udp    660
  307.  
  308.     - You may also run "rpcinfo -u localhost ypbind". This command
  309.       should produce something like:
  310.  
  311.         program 100007 version 2 ready and waiting
  312.  
  313.  
  314. Finally, do not forget that for host lookups you must set (or add)
  315. "nis" to the lookup order line in your /etc/host.conf file. Please read
  316. the manpage `resolv+.8' for more details.
  317.  
  318. At this point you should be able to use NIS client programs like ypcat,
  319. etc...  For example, "ypcat passwd" will give you the entire NIS
  320. password database.
  321.  
  322. IMPORTANT: If you skipped the test procedure then make sure you have set
  323. the domain name, and created the directory:
  324.  
  325.     /var/yp
  326.  
  327. This directory MUST exist for ypbind to start up succesfully.
  328.  
  329. If the test worked you may now want to change the files /etc/rc.d/rc.M
  330. and /etc/rc.d/rc.inet2 on your system so that ypbind will be started up
  331. at boot time and your system will act as a NIS client. Edit the file
  332. /etc/rc.d/rc.M and look for the commands which set the domain name.
  333. Change the domain name into the name of your domain. Also, edit the
  334. file /etc/rc.d/rc.inet2, comment out the lines which start up the
  335. rpc.portmap daemon, and add the following lines just after the place
  336. where rpc.portmap is started:
  337.  
  338.     #
  339.     # Start the ypbind daemon
  340.     #
  341.     if [ -f ${NET}/ypbind -a -d /var/yp ]; then
  342.         echo -n " ypbind"
  343.         ${NET}/ypbind
  344.     fi
  345.  
  346. Unlike Sun's implementation of NIS you do not need to edit /etc/passwd
  347. and /etc/group to take advantage of NIS. Sun's implementation needs a
  348. line "+:*:0:0:::" in /etc/passwd and a line "+:*:0:" in /etc/group to
  349. tell NIS to search the NIS password and group databases.
  350.  
  351. Well, that's it. Reboot the machine and watch the boot messages to see
  352. if ypbind is actually started.
  353.  
  354. IMPORTANT: Note that the netgroup feature is not yet implemented.
  355. Netgroups allow access control for every machine and every user in
  356. the NIS domain, and they require an entry like:
  357.  
  358.     +@this_machine_users
  359.  
  360. in /etc/passwd. At this moment, every user in the NIS password database
  361. can access your linux machine if you run "ypbind".
  362.  
  363.  
  364. 5. What you need to set up NYS?
  365.  
  366. 5.1 Determine whether you are a Server, Slave or Client.
  367.  
  368. To answer this question you have to consider two cases:
  369.  
  370.     1. Your machine is going to be part of a network with
  371.        existing NIS servers
  372.  
  373.     2. You do not have any NIS servers in the network yet
  374.  
  375. In the first case, you only need to relink all client and deamon
  376. programs with the NYS library libnsl.so (or statically link them with
  377. libnsl.a). This means adding the line
  378.  
  379.     LIBS=-lnsl
  380.  
  381. to your Makefile signifing you want to link the Network Services
  382. Library.
  383.  
  384. Basically all network deamons and the `login' program need to be
  385. recompiled.  In no way is this an easy task, and a full "NYS aware"
  386. suite of programs is being gathered.
  387.  
  388. Similarly like in the case of the standard NIS, if you don't have NIS
  389. servers, then you will also need a NIS server program (usually called
  390. ypserv) and you have to designate one of the machines in your network
  391. as a master NIS server. Again, you might want to set up at least one
  392. slave server as well.
  393.  
  394.  
  395. 5.2 The Software
  396.  
  397. You need to retrieve and compile the NYS services library libnsl.so.
  398. If you don't have the DLL tools installed you may retrieve a
  399. precompiled shared, static and stub library from the same site
  400. mentioned below.
  401.  
  402. The NYS library (source and precompiled version)  can be obtained from:
  403.  
  404.   Site                   Directory                         File Name
  405.  
  406.   nic.funet.fi           /pub/OS/Linux/BETA/NYS            nys-0.26.tar.gz
  407.   nic.funet.fi           /pub/OS/Linux/BETA/NYS/lib        libnsl.so.1.0.a26
  408.  
  409. Precompiled `login' and `su' programs may also be fetched from
  410.  
  411.   Site                   Directory                         File Name
  412.  
  413.   nic.funet.fi           /pub/OS/Linux/BETA/NYS/bin        login
  414.   nic.funet.fi           /pub/OS/Linux/BETA/NYS/bin        su
  415.  
  416. Similarly, example configuration files may be retrieved from
  417.  
  418.   Site                   Directory                         File Name
  419.  
  420.   nic.funet.fi           /pub/OS/Linux/BETA/NYS/etc        *conf
  421.  
  422. For compilation of the nsl library, please follow the instructions
  423. which come with the software. If you wish to compile the shared DLL
  424. library you must have the DLL tools installed in the standard place
  425. (/usr/dll). The DLL tools (the package tools-2.11.tar.gz) can be
  426. obtained from many sites.
  427.  
  428.  
  429. 5.3. Setting up a NYS Client
  430.  
  431. Unlike NIS, there is no setting up required for a NYS client. All that
  432. is required is that the configuration files (/etc/yp.conf,
  433. /etc/nis.conf) point to the correct servers for their information. See
  434. the examples provided with the source code.
  435.  
  436.  
  437. 5.4. The nsswitch.conf File
  438.  
  439. The Network Services switch file /etc/nsswitch.conf determines the
  440. order of lookups performed when a certain piece of information is
  441. requested, just like the /etc/host.conf file which determines the way
  442. host lookups are performed. Again, look at at the example file provided
  443. in the source distribution. For example, the line
  444.  
  445.     hosts: files nis dns
  446.  
  447. specifies that host lookup functions should first look in the local
  448. /etc/hosts file, followed by a NIS lookup and finally thru the domain
  449. name service (/etc/resolv.conf and named), at which point if no match
  450. is found an error is returned.
  451.  
  452.  
  453. 6. Setting up a NYS Server
  454.  
  455. The NIS/NYS server software can be found on:
  456.  
  457.   Site                   Directory                         File Name
  458.  
  459.   ftp.lysator.liu.se    /pub/NYS                           ypserv-0.5.tar.gz
  460.   ftp.univie.ac.at      /unix/system/linux/funet/BETA/NYS  ypserv-0.5.tar.gz
  461.   mcsun.eu.net          /os/linux/BETA/NYS                 ypserv-0.5.tar.gz
  462.  
  463. The server setup is the same for both NIS and NYS.
  464.  
  465. Compile the software to generate the 'ypserv', 'dbcat' and 'dbload'
  466. programs.  Firstly, determine what files you require to be available
  467. via NIS/NYS and then add or remove the appropriate entries to the
  468. ypMakefile. Now build the DBM files by
  469.  
  470.     % make -f ypMakefile
  471.  
  472. Make sure the portmapper (rpc.portmap) is running, and start the
  473. server 'ypserv'. The command
  474.  
  475.     % rpcinfo -u localhost ypserv
  476.  
  477. should output something like
  478.  
  479.     program 100004 version 2 ready and waiting
  480.  
  481. That's it, your server is up and running.
  482.  
  483.  
  484. 7. Verifying the NIS/NYS Installation
  485.  
  486. If everything is fine (as it should be), you should be able to verify
  487. your installation with a few simple commands. Assuming, for example,
  488. your passwd file is being supplied by NIS/NYS, the command
  489.  
  490.     % ypcat passwd
  491.  
  492. should give you the contents of your NIS passwd file. The command
  493.  
  494.     % ypmatch userid passwd
  495.  
  496. (where userid is the login name of an arbitrary user) should give you
  497. the user's entry in the NIS passwd file. The 'ypcat' and 'ypmatch'
  498. programs should be included with your distribution of NIS or NYS.
  499.  
  500.  
  501. 8. Common Problems and Troubleshooting NIS
  502.  
  503. Here are some common problems reported by various users:
  504.  
  505.     1) The libraries for 4.5.19 are broken. NIS won't work with it.
  506.  
  507.     2) If you upgrade the libraries from 4.5.19 to 4.5.24 then the
  508.        su command breaks. You need to get the su command from the
  509.        slackware 1.2.0 distribution. Incidentally that's where you
  510.        can get the updated libraries.
  511.  
  512.     3) You could run into trouble with NIS and DNS on the same machine.
  513.        My DNS server occasionally will not bring up NIS. Haven't yet
  514.        tracked down why.
  515.  
  516.     4) When a NIS server goes down and comes up again ypbind starts
  517.        complaining with messages like:
  518.  
  519.          yp_match: clnt_call:
  520.                      RPC: Unable to receive; errno = Connection refused
  521.  
  522.        and logins are refused for those who are registered in the
  523.        NIS database. Try to login as root and if you succeed, then kill
  524.        ypbind and start it up again.
  525.  
  526.  
  527. 9. Frequently Asked Questions
  528.  
  529. Most of your questions should be answered by now. If there are still
  530. questions unanswered you might want to post a message to
  531.  
  532.     comp.os.linux.help
  533.  
  534. or contact one of the authors of this HOWTO.
  535.